//---------------------------------------------------------------------
// 
function EditTaskInline(id) {
    if (in_ajax != 1) 
        {
            in_ajax = 1;
            $.get('/task/edit_inline/', {"item_id": id}, function(data){ 
              	$("#task_"+id).html('<td class="inline_edit" colspan=5><div class="form_layer">' + data + '</div></td>'); 
               	in_ajax = 0;
               	AddHelperButtons();
               	DateTimeShortcuts.init();
               	document.getElementById("id_name").focus();
               	});
       	}
}

//---------------------------------------------------------------------
// 
function SaveTaskInline(id, confirm) {
    if (confirm == 'yes') {
    	if (in_ajax != 1) {
    		in_ajax = 1;

			item_id = $("#id_item_id").val();
    		name = $("#id_name").val();
    		project = $("#id_project").val();
    		task_date = $("#id_task_date").val();
    		time_spent = $("#id_time_spent").val();
    		text = $("#id_text").val();

    		if (document.getElementById("id_done").checked) 
    			{
    			var done = $("#id_done").val();
    			}
    		else {
    			var done = "";
    		}


    	$("#task_"+id).html("<td colspan=5><img src='/appmedia/wait.gif'></td>");
        $.post('/task/edit_inline/', {"item_id": item_id, "name": name, "project": project, "task_date": task_date, "time_spent": time_spent, "text": text, "done": done}, function(data){
               	in_ajax = 0;
               	$("#task_"+id).html(data);
               	});

		}
    }
    else {
    	item_id = $("#id_item_id").val();
    	$.get('/task/get_inline/', {"item_id": item_id}, function(data){
               	in_ajax = 0;
               	$("#task_"+id).html(data);
               	});
    }
}

//---------------------------------------------------------------------
// 
function ChangeNumber(delta, id) {
	var val = $("#"+id).val();
	if (val=="") {
		var num = 0.0 + delta;
	}
	else {
		var num = parseFloat(val) + delta;
	}
	if (num < 0.0) { num=0; }
		$("#"+id).val(num.toFixed(2));
	}

//---------------------------------------------------------------------
// 
function AddHelperButtons() {
$("input.vFloatField").each(function(){
    $(this).after('<a href="javascript:ChangeNumber(-0.5, ' + "'" + this.id + "'" +')">-0.5</a>');
    $(this).after(' <a href="javascript:ChangeNumber(0.5, ' + "'" + this.id + "'" +')">+0.5</a> / ');
    });
}